<template>
	<div id='read'>
		<p v-html='blog.title'></p>
		<p v-html='blog.hot'></p>
		<p v-html='blog.time'></p>
		<p v-html='blog.characte'></p>
	</div>
</template>
<script>
	export default {
		name: 'read',
		data() {
			return {
				blog: {
					"time": "这是时间，正在加载中...",
					"hot": "这是摘要，正在加载中...",
					"title": "这是标题，正在加载中...",
					"characte": "这是正文，正在加载中..."
				}
			}
		},
		created() {
			this.getBlogContent();
		},
		props: {
			id: {
				type: String,
				default: '0'
			}
		},
		methods: {
			// 发送请求获取博客正文
			getBlogContent: function() {
				var that = this;
				this.$axios.get('http://localhost:8080/MyHomePage/readContent.do', {
						params: {
							id: parseInt(that.id)
						}
					})
					.then(function(response) {
						console.log(response);
						var code = response.data.code;
						if (code == 'success') {
							that.blog = response.data.data;
							var imgs = document.getElementsByTagName('img');
							alert('开始');
							for(var i=0; i<imgs.length; i++){
								var thisImg = imgs[i].src;
								alert(thisImg);
							}
						} else {
							// 错误事件处理
							that.$notify.error({
								title: '错误',
								message: '网络错误，请重试！'
							});
						}
					})
					.catch(function(error) {
						// 错误事件处理
						that.$notify.error({
							title: '错误',
							message: '网络错误，请重试！'
						});
					});
			}
		}
	}

</script>
<style scoped="true">
	#read {}

</style>
